﻿using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using XYS.Core.Util.Helper;
using XYS.Service.Core.Models;

namespace XYS.Core.Util;
public static partial class Extention
{
    /// <summary>  
    /// 获取枚举变量值的 Description 属性  
    /// </summary>  
    /// <typeparam name="T">枚举类型</typeparam>
    /// <param name="enumValue">枚举值</param>
    /// <returns>如果包含 Description 属性，则返回 Description 属性的值，否则返回枚举变量值的名称</returns>  
    public static string GetDescription<T>(this T enumValue)
        where T : Enum
    {
        return EnumHelper.GetDescription(enumValue);
    }

    /// <summary>
    /// 获取所有枚举值
    /// </summary>
    /// <param name="_"></param>
    /// <returns></returns>
    public static List<T> ToList<T>(this T _)
        where T : Enum
    {
        return EnumHelper.ToList<T>();
    }


    /// <summary>
    /// 是否激活某个服务
    /// </summary>
    /// <param name="activateServiceSource"></param>
    /// <param name="activateService"></param>
    /// <returns></returns>
    public static bool IsActivateService(this EnumActivateService activateServiceSource, EnumActivateService activateService) => (activateServiceSource & activateService) == activateService;

    /// <summary>
    /// 是否拥有某个部门职责
    /// </summary>
    /// <param name="deptServiceSource"></param>
    /// <param name="deptService"></param>
    /// <returns></returns>
    public static bool IsActivateService(this EnumDeptService deptServiceSource, EnumDeptService deptService) => (deptServiceSource & deptService) == deptService;

}